package com.springboot.demo.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/*
 *DATE:2025/7/8
 */
@Component
@Aspect
public class Audience {
    @Pointcut("execution(* com.springboot.demo.aop.Performer.perform(..))")
    public void pc(){

    }
    @Before("pc()")
    public void takeSeat(){
        System.out.println("观众坐下");
    }

    @Before("pc()")
    public void turnOffCellPhone(){
        System.out.println("关闭手机");
    }

    @AfterReturning("pc()")
    public void applaud(){
        System.out.println("观众鼓掌");
    }

    @AfterThrowing("pc()")
    public void throwEggs(){
        System.out.println("观众抛鸡蛋");
    }

    @Around("pc()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("环绕前");
        Object obj = joinPoint.proceed();
        System.out.println("环绕后");
        return obj;
    }
}
